package com.zhu.scan.process;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.stereotype.Component;

/**
 * @ClassName MyBeanDefinitionPostProcess
 * @Description TODO
 * @Author zhuxiongbin
 * @Date 2021-11-05 13:57
 * @Version 1.0.0
 */
@Component
public class MyBeanDefinitionPostProcess implements BeanDefinitionRegistryPostProcessor {

    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {

    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory)configurableListableBeanFactory;
        //是否允许使用相同名称重新注册不同的bean实现.
        defaultListableBeanFactory.setAllowBeanDefinitionOverriding(false);
        //是否允许循环依赖
        defaultListableBeanFactory.setAllowCircularReferences(false);

    }
}
